cbuffer cbPerObject
{
    float3 Color;
};

Texture2D<float4> AlbedoBuffer;

Texture2DMS<float4> AlbedoBufferMSAA;

struct VS_IN
{
    float4 Position : POSITION;
};

struct VS_OUT
{
    float2 TexCoord : TEXCOORD;
    float4 Position : SV_POSITION;
};

VS_OUT VS(VS_IN vIn)
{
    VS_OUT vOut;
    vOut.TexCoord = mad(vIn.Position.xy, float2(0.5, -0.5), 0.5);
    vOut.Position = vIn.Position;
    return vOut;
}

float4 PSMSAA(VS_OUT pIn, uint iSampleIndex : SV_SAMPLEINDEX) : SV_TARGET
{
    float4 albedo_buf = AlbedoBufferMSAA.Load((int2)pIn.Position, iSampleIndex);
    return float4(albedo_buf.xyz*Color, 1.0);
}

float4 PS(VS_OUT pIn) : SV_TARGET
{
    float4 albedo_buf = AlbedoBuffer.Load(int3((int2)pIn.Position, 0));
    return float4(albedo_buf.xyz*Color, 1.0);
}

technique10 MSAALighting
{
    pass P0
    {
        SetVertexShader(CompileShader(vs_4_1, VS()));
        SetGeometryShader(NULL);
        SetPixelShader(CompileShader(ps_4_1, PSMSAA()));
    }
}

technique10 StandardLighting
{
    pass P0
    {
        SetVertexShader(CompileShader(vs_4_1, VS()));
        SetGeometryShader(NULL);
        SetPixelShader(CompileShader(ps_4_1, PS()));
    }
}
